/**
 * 
 */
package com.delta.rafg.core.base;

import javax.servlet.http.HttpServletRequest;

import com.delta.rafg.core.AObjectHelperImpl;
import com.delta.rafg.coredata.ARequest;

/**
 * @author D9785692
 *
 */
public class ARafgObjectHelperImpl extends AObjectHelperImpl {
    
    /**
     * This method is used for getting browser information
     * @param request
     * @return
     */
    private String getBrowserInfo(final HttpServletRequest request) {

        final String ua = request.getHeader("User-Agent");
        final boolean isFirefox = ua != null && ua.indexOf("Firefox/") != -1;
        final boolean isMSIE = ua != null && ua.indexOf("MSIE") != -1;
        String theBrowser = "";
        if (isMSIE) {
            theBrowser = "Internet Explorer";
        } else if (isFirefox) {
            theBrowser = "Firefox";
        }
        return theBrowser;
    }

    /**
     * This method is used for setting request info into the HttpServletRequest
     * @param pRafgRequest
     * @param pRequest
     */
    public void setHttpData(final Object pRafgRequest,
        final Object pRequest) {
    	
		ARequest aRafgRequest = (ARequest)pRafgRequest;
        HttpServletRequest aHttpRequest = (HttpServletRequest)pRequest;    	

        aRafgRequest.setHttpData(getBrowserInfo(aHttpRequest), aHttpRequest
            .getRemoteHost(), aHttpRequest.getSession(false).getId(), aHttpRequest
            .getLocale().getLanguage());
    	
    }
    
}
